package comits.web.client.servlets.demo;



import java.io.IOException;
import java.util.ArrayList;

import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import comits.business.tiers.metiers.*;
import comits.business.tiers.rp.tasks.ws.ControleurCalculStockSecu;





public class MenuStockSecuServlet extends HttpServlet{
	
	/**
	 * 
	 * @author Ismahene
	 */
	private static final long serialVersionUID = 7526928611471348888L;

	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
	
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String action = request.getParameter("action");
		
		if(action.equals("Calculer Stock Securite par boutique et produit")){
			
			List<Boutique> BList=new ArrayList();
			ControleurCalculStockSecu ss=new ControleurCalculStockSecu();
			BList=ss.recuplisteboutique();
			request.setAttribute("boutique",BList);
			getServletContext().getRequestDispatcher("/AfficheSs.jsp").forward(request, response);

			
		} else if (action.equals("Calculer Stock Securite pour toutes les boutiques")) {
	
			getServletContext().getRequestDispatcher("/AfficheSsAllBoutiques.jsp").forward(request, response);
		
		} else if (action.equals("Calculer/modifier couverture moyenne d'une classe de produits")) {
			List<Boutique> BList1=new ArrayList();
			ControleurCalculStockSecu ss=new ControleurCalculStockSecu();
			BList1=ss.recuplisteboutique();
			request.setAttribute("boutique",BList1);
			getServletContext().getRequestDispatcher("/Modifcouverturemoyenne.jsp").forward(request, response);
			
		}else if (action.equals("Afficher ou modifier informations relatives au Stock de securite")) {
			
			List<Boutique> BList1=new ArrayList();
			ControleurCalculStockSecu ss=new ControleurCalculStockSecu();
			BList1=ss.recuplisteboutique();
			request.setAttribute("boutique",BList1);
			getServletContext().getRequestDispatcher("/recherchepourss.jsp").forward(request, response);
			
		}
		
	}
	
	/**
	 * Returns a short description of the servlet.
	 * 
	 * @return a String containing servlet description
	 */
	public String getServletInfo() {
		return "Short description";
	}// </editor-fold>
}
 
